package com.yonyou.crm.bpub.refervalue.service;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yonyou.crm.bpub.refervalue.entity.ReferDataVO;
import com.yonyou.crm.common.page.entity.Page;
import com.yonyou.crm.sys.org.entity.SysOrgTypeEnum;
import com.yonyou.crm.sys.org.entity.SysOrgVO;
import com.yonyou.crm.sys.org.service.SysOrgBizServiceImpl;

@Service
public class OrgRefervalue extends BaseRefervalue{

	@Autowired
	SysOrgBizServiceImpl service;
	
	@Override
	public <T extends Serializable> List<ReferDataVO> getRefervalues(Page<T> page, Map<String, Object> paraMap) {
		if (paraMap == null) {
			paraMap = new HashMap<String, Object>();
		}
		paraMap.put("orgType", SysOrgTypeEnum.COMPANY.getValue());
		List<SysOrgVO> list = service.getRefervaluesForApp((Page<SysOrgVO>)page, paraMap);

		List<ReferDataVO> rsList = new ArrayList<ReferDataVO>();
		for (SysOrgVO vo : list) {
			ReferDataVO referDataVO = new ReferDataVO();
			referDataVO.setId(vo.getId().toString());
			referDataVO.setValue(vo.getName());
			List<String> itemDataList = new ArrayList<>();
			itemDataList.add(vo.getName());
			//TODO 根据funcode决定返回的数据内容

			referDataVO.setItemdatalist(itemDataList);
			
			rsList.add(referDataVO);
		}
		
		return rsList;
	}

}
